package com.example.algorithm.utils;

import com.example.algorithm.department.DepartmentCoordination;
import com.example.algorithm.department.DepartmentMainResponsibility;

import java.util.HashMap;

public class GetMapKeyUtils {
    //根据value值获取到对应的一个key值
   public static String getKey1(HashMap<String, DepartmentMainResponsibility> map, DepartmentMainResponsibility value){
              String key = null;
            //Map,HashMap并没有实现Iteratable接口.不能用于增强for循环.
                for(String getKey: map.keySet()){
                       if(map.get(getKey).equals(value)){
                             key = getKey;
                         }
                   }
               return key;
               //这个key肯定是最后一个满足该条件的key.
           }
    public static String getKey2(HashMap<String, DepartmentCoordination> map, DepartmentCoordination value){
        String key = null;
        //Map,HashMap并没有实现Iteratable接口.不能用于增强for循环.
        for(String getKey: map.keySet()){
            if(map.get(getKey).equals(value)){
                key = getKey;
            }
        }
        return key;
        //这个key肯定是最后一个满足该条件的key.
    }
}
